gii无法访问 yii2 |
您所在的位置:网站首页 › 提示403 forbidden › gii无法访问 yii2 |
今天尝试在家里连接公司外部服务器的yii框架的gii功能,提示 Forbidden (#403) You are not allowed to access this page. 于是花了较长的时间在百度和论坛上寻找yii2 外部pc端访问gii功能时的配置方法, 大多都是说需要找到main.php文件,然后改变默认的ip访问地址(127.0.0.1)实现, 但是找了半天无果。 自己官网文档找了好久解决方案如下: 在文件vendor\yiisoft\yii2-gii\Module.php 中 /** * @var array the list of IPs that are allowed to access this module. * Each array element represents a single IP filter which can be either an IP address * or an address with wildcard (e.g. 192.168.0.*) to represent a network segment. * The default value is `['127.0.0.1', '::1']`, which means the module can only be accessed * by localhost. */ public $allowedIPs = ['115.123.134.185(替换为你现在的电脑ip)', '::1']; 解决了一个小问题。 2016-07-13 更正: 本着不随意修改源码的原则, 直接在配置文件进行配置修改; 修改如下: 在config/main-local.php中加入: 'allowedIPs' => ['127.0.0.1', '::1','*'], // 这里允许所有用户加载gii 详细如下: if (!YII_ENV_TEST) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1','*'], // 这里允许所有用户加载gii ]; } |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |